import java.util.Arrays;

public class MyStack {
    public int[] elem;
    public int usedSize;
    public MyStack(){
        this.elem=new int[10];
    }
    public void push(int val){
        if(IsFull()){
            this.elem= Arrays.copyOf(elem,2*elem.length);
        }
        elem[usedSize++]=val;
    }
    public boolean IsFull(){
        return elem[usedSize]==elem[10];
    }
    public int pop(){
        if(isEmpty()){
            throw new RuntimeException();
        }
        int val=elem[usedSize-1];
        usedSize--;
        return val;
    }
    public int peek(){
        if(isEmpty()){
            throw new RuntimeException();
        }
        int val=elem[usedSize-1];
        return val;
    }
    public boolean isEmpty() {
        return usedSize==0;
    }
}
